package run.theo.mallorder.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import run.theo.mallcommons.entity.MallOrder;
import run.theo.mallorder.mapper.MallOrderMapper;
import run.theo.mallorder.service.MallOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author theo
 * @since 2022/10/16 14:38
 */
@Service
public class MallOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrder> implements MallOrderService {

    int i = 0;
    @Override
    @SentinelResource(
            value = "m2",
            blockHandlerClass = MallOrderServiceImplBlockHandlerClass.class,
            blockHandler = "blockHandler",
            fallbackClass = MallOrderServiceImplFallbackClass.class,
            fallback = "fallback"
    )
    public String exceptionTest() {
        i++;
        if (i % 3 == 0){
            throw new RuntimeException();
        }
        return "testThrowable";
    }
}
